package controller;

import observerNotification.ObserverNotification;
import observerNotification.QuestionObserverNotification;


/**
 * Sets specific control methods for the <b>sharing file</b> state.
 * 
 * <p>
 * <ul>
 * <li>Project: 	ChatSystemG3</li>
 * <li>Called by: 	controller.*</li>
 * </ul>
 * </p>
 * 
 * @author COMBES Nicolas - LECHANTRE Arnaud
 * @see State
 */
public class SharingFileState extends ConnectedState {
	
	/**
	 * Number of actual file transfer
	 */
	private int numberOfTransfer;
	/**
	 * Number of file transfer limit (in the same time)
	 */
	private static int transferLimit=10;	
	
	/**
	 * Construct
	 */
	SharingFileState(){
		this.numberOfTransfer=1;
	}
	
	@Override
	public ObserverNotification performDisconnect() {
		return new QuestionObserverNotification("Your file transfer are not finished, do you really wan't to close the chat?", "disconnect");
	}
	
	@Override
	public int shareNewFile() {
		if(this.numberOfTransfer<transferLimit){
			this.numberOfTransfer++;
			return numberOfTransfer;
		}else{
			return -1;
		}
		
	}
	
	@Override
	public int transferFinished() {
		this.numberOfTransfer--;
		return this.numberOfTransfer;
		
	}
}
